package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.TechnologiesCommentVO;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2018/1/12 18:45:58
 * 修改备注：
 * ================================================
 */

public class ExpCommentHolder extends BaseViewHolder<TechnologiesCommentVO> {

    private TextView tvName;//用户名
    private TextView tvTime;//日期
    private TextView tvPraise;//点赞数
    private TextView tvContent;//内容


    public ExpCommentHolder(ViewGroup parent) {
        super(parent, R.layout.item_technologies_comment);

        tvName = $(R.id.tv_name);
        tvTime = $(R.id.tv_time);
        tvPraise = $(R.id.tv_praise);
        tvContent = $(R.id.tv_content);
    }

    @Override
    public void setData(final TechnologiesCommentVO data) {
        super.setData(data);

        tvName.setText(!StringUtil.isStrEmpty(data.getMobilePhone()) ? data.getMobilePhone() : "匿名用户");
        tvTime.setText(data.getCreateTime());
//        tvPraise.setText(data.getPraiseNum());
        tvContent.setText(data.getContent());

        tvPraise.setVisibility(View.GONE);

//        if (data.isOnclick()) {
//            Drawable drawable = getContext().getResources().getDrawable(R.drawable.icon_praise);
//            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
//            tvPraise.setCompoundDrawables(null, null, drawable, null);
//        } else {
//            Drawable drawable = getContext().getResources().getDrawable(R.drawable.icon_praise_none);
//            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
//            tvPraise.setCompoundDrawables(null, null, drawable, null);
//        }
//
//        tvPraise.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                if (!data.isOnclick()) {
//                    Drawable drawable = getContext().getResources().getDrawable(R.drawable.icon_praise);
//                    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
//                    tvPraise.setCompoundDrawables(null, null, drawable, null);
//                    tvPraise.setText(data.getPraiseNum() + 1 + "");
//                    data.setOnclick(true);
//                    BusinessTechnologies.clickPraise((Activity) getContext(), data.getId(), new Handler());
//                }
//            }
//        });
    }

}
